<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="<%=request.getContextPath()%>/"/>
    <meta charset="UTF-8">
    <title>编辑医院</title>
    <link rel="stylesheet" href="statics/css/hisStyle.css">
    <link rel="stylesheet" href="statics/css/common-styles.css">
</head>
<body>
<%@include file="../common/sidebar.jsp"%>
<div class="main-content">
    <%@include file="../common/top.jsp"%>
    <div class="content">
        <div class="function-page">
            <!-- 页面标题 -->
            <div class="page-header">
                <h1>编辑医院</h1>
            </div>

            <!-- 错误提示 -->
            <c:if test="${not empty sessionScope.error}">
                <div class="message-error">
                    ${sessionScope.error}
                    <% session.removeAttribute("error"); %>
                </div>
            </c:if>
            
            <form action="hospital/modify" method="post" class="form-container">
                <!-- 隐藏域传递医院ID -->
                <input type="hidden" name="hospitalid" value="${sessionScope.editHospital.hospitalid != null ? sessionScope.editHospital.hospitalid : hospital.hospitalid}"/>
                <div class="form-group">
                    <label for="hospitalname">医院名称：</label>
                    <input type="text" id="hospitalname" name="hospitalname" value="${sessionScope.editHospital.hospitalname != null ? sessionScope.editHospital.hospitalname : hospital.hospitalname}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="address">地址：</label>
                    <input type="text" id="address" name="address" value="${sessionScope.editHospital.address != null ? sessionScope.editHospital.address : hospital.address}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="hphone">联系电话：</label>
                    <input type="text" id="hphone" name="hphone" value="${sessionScope.editHospital.hphone != null ? sessionScope.editHospital.hphone : hospital.hphone}" class="form-control" required>
                </div>
                <div class="form-actions">
                    <a href="hospital/find" class="btn btn-default">取消</a>
                    <button type="submit" class="btn btn-primary">保存修改</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
  // 页面加载完成后清除session中的表单数据，避免下次打开页面时仍显示上次的数据
  window.onload = function() {
    <% session.removeAttribute("editHospital"); %>
  };
</script>
</body>
</html>